<body class="back">
<p><%= flash[:notice] %></p>
<%= render 'head' %></br>
<div>
  <h1 align="center">个人信息情况表</h1></br>
  <div class="container">
    <div class="row">
      <div class="col-md-4 login">
        <input type="text" class="form-control" id="name" placeholder="请输入姓名">
      </div>
      <div class="col-md-4 login">
        <input type="text" class="form-control" id="tel" placeholder="请输入手机号码">
      </div>
      <div class="col-md-4 login">
        <input type="text" class="form-control" id="card" placeholder="请输入身份证号码">
      </div>
      <div class="col-md-4 login">
        <input type="text" class="form-control" id="age" placeholder="请输入年龄">
      </div>
      <div class="col-md-4 login">
        <input type="text" class="form-control" id="add" placeholder="请输入住址">
      </div>
      <div class="col-md-4 login">
        <input type="text" class="form-control" id="sex" placeholder="请输入性别">
      </div>
    </div></br>

  </div>
  <div class="container">
    <div class="row">
      <%= render 'body' %>
      <div>
      <tr>
        <td><p><%= @record_result.try(:score_result) %></p></br></td>
        <% @data.each do |data| %>
        <td colspan="6"><%= raw data['describe'] %></td>
      </tr>
      <% end %>
    </div>
      <button type="button" class="btn btn-default" id="btn">提交</button>
    </div>
  </div>
</div>
</body>
<script>
$(document).ready(function(){
  $("#btn").click(function(){
    var sum1=0,sum2=0,sum3=0,sum4=0,sum5=0,sum6=0,sum7=0,sum8=0,sum9=0;
    var a1 = 0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,a8=0,a9=0;
    $(":radio[class='group1']:checked").each(function(index,dom){
      a1 =parseInt( $(dom).val());
      sum1 = sum1 + a1;
    });
    $(":radio[class='group2']:checked").each(function(index,dom){
      a2 =parseInt( $(dom).val());
      sum2 = sum2 + a2;
    });
    $(":radio[class='group3']:checked").each(function(index,dom){
      a3 =parseInt( $(dom).val());
      sum3 = sum3 + a3;
    });
    $(":radio[class='group4']:checked").each(function(index,dom){
      a4 =parseInt( $(dom).val());
      sum4 = sum4 + a4;
    });
    $(":radio[class='group5']:checked").each(function(index,dom){
      a5 =parseInt( $(dom).val());
      sum5 = sum5 + a5;
    });
    $(":radio[class='group6']:checked").each(function(index,dom){
      a6 =parseInt( $(dom).val());
      sum6 = sum6+ a6;
    });
    $(":radio[class='group7']:checked").each(function(index,dom){
      a7 =parseInt( $(dom).val());
      sum7 = sum7 + a7;
    });
    $(":radio[class='group8']:checked").each(function(index,dom){
      a8 =parseInt( $(dom).val());
      sum8 = sum8 + a8;
    });
    $(":radio[class='group9']:checked").each(function(index,dom){
      a9 =parseInt( $(dom).val());
      sum9 = sum9 + a9;
    });
    var name =$("#name").val();
    var tel =$("#tel").val();
    var card =$("#card").val();
    var sex = $("#sex").val();
    var age = $("#age").val();
    var add = $("#add").val();
    var data = {"tel":tel,"name":name,"card":card,"score1":sum1,"score2":sum2,"score3":sum3,"score4":sum4,"score5":sum5,"score6":sum6,"score7":sum7,"score8":sum8,"score9":sum9,"sex":sex,"age":age,"add":add}
    $.ajax({
     type: "POST",
     url: "/healthmanage/score",
     data: data,
    });
  });
});
</script>
